<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>药品审核</title>
    <link rel="stylesheet" href="../../../layui/css/layui.css">
</head>
<body>
<div class="layui-fluid">
    <!-- 药品审核 -->
    <div class="layui-row">
        <fieldset class="layui-elem-field site-demo-button layui-col-md-offset2 layui-col-md8"
                  style="margin-top: 30px;padding:15px;">
            <legend>药品审核</legend>
            <form class="layui-form layui-form-pane" lay-filter="submit-audit" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">药品名</label>
                        <div class="layui-input-block">
                            <!-- 隐藏表单域用于存放药品 id -->
                            <input type="hidden" name="id">
                            <input type="text" name="name" disabled class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">生产厂商</label>
                        <div class="layui-input-block">
                            <input type="text" name="productCompany" disabled class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">审核意见</label>
                        <div class="layui-input-block">
                            <input type="radio" name="examStatus" value="2" title="通过" checked="">
                            <input type="radio" name="examStatus" value="3" title="不予通过">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">审核意见</label>
                    <div class="layui-input-block">
                    <textarea placeholder="请填写审核意见" class="layui-textarea"
                              name="examAdvice"></textarea>
                    </div>
                </div>
                <div class="layui-form-item" style="text-align: center;">
                    <div class="layui-inline">
                        <button class="layui-btn" lay-submit="" lay-filter="submit-audit">添加审核</button>
                    </div>
                </div>
            </form>
        </fieldset>
    </div>
</div>


<script src="../../../layui/layui.js"></script>
<script>
    layui.use(['jquery', 'table', 'form'], function () {
        var $ = layui.jquery; // 注册 jquery 组件
        var form = layui.form;// 注册 form 组件

        // 当前地址
        var url = window.location.href;
        // 获取药品 id
        var id = url.substring(url.lastIndexOf('=') + 1);

        //根据id 通过 ajax 请求获取药品信息，并对数据进行回显

        //表单数据回显
        form.val('submit-audit', {
            id: "101",
            name: "止咳糖浆",
            productCompany: "哈药集团制药六厂",
            examStatus: 3,
            examAdvice: "过年不发红包，不让他审核通过"
        });


        form.on('submit(submit-audit)', function (data) {
            console.log(data.elem); //被执行事件的元素DOM对象，一般为button对象
            console.log(data.form); //被执行提交的form对象，一般在存在form标签时才会返回
            console.log(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
            return false;
        });
    });
</script>
</body>
</html>
